'use strict';

angular.module('app')
    .controller('subscribeDetailController', ['$scope', '$rootScope', '$state', '$timeout',
        function($scope, $rootScope, $state, $timeout) {
            var title = "订阅消息详情";
            var id = $state.params.id;
            $scope.title = $rootScope.title = title;
            $scope.loading = true;
            getselectChannel();
            activate(id);
            function getselectChannel(){
                $scope.loading = true;
                $.ajax({
                    url : $scope.app.project_name+ '/thirdPlatform/channel/selectChannel'
                }).then(function(result) {
                    $scope.loading = false;
                    if (result.httpCode == 200) {
                        $scope.channelList = result.data;
                    } else {
                        $scope.msg = result.msg;
                    }
                    $scope.$apply();
                });
            }
            // 初始化页面
            function activate(id) {
                $scope.loading = true;
                $.ajax({
                    url : $scope.app.project_name + '/subscribe/read/detail',
                    data: {'id': id}
                }).then(function(result) {
                    $scope.loading = false;
                    if (result.httpCode == 200) {
                        $scope.record = result.data;
                        var  openPlatforms =  result.data.openPlatform;
                        var plat=openPlatforms.split(",");
                        var str="";
                        for(var i=0;i<plat.length;i++){
                            if(plat[i]=='lbjr'){
                                str+="联璧金融  ";
                            }
                            if(plat[i]=='ld'){
                                str+="铃铛  ";
                            }
                            if(plat[i]=='lbn'){
                                str+="老板娘  ";
                            }
                            if(plat[i]=='zqh'){
                                str+="智仟汇";
                            }

                        }
                        $("#platOpen").html(str);
                        $("#pageStyle").attr("disabled",true);
                        $("#channelNo").attr("disabled",true);
                    } else {
                        $scope.msg = result.msg;
                    }
                    $scope.$apply();
                });
            }

    } ]);